<!DOCTYPE html>





<html class="theme-next gemini use-motion" lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="generator" content="Hexo 3.9.0">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=7.3.0">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/penguin-32px-next.png?v=7.3.0">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/penguin-16px-next.png?v=7.3.0">
  <link rel="mask-icon" href="/images/logo.svg?v=7.3.0" color="#222">

<link rel="stylesheet" href="/css/main.css?v=7.3.0">


<link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css?v=4.7.0">
  <script src="/lib/pace/pace.min.js?v=1.0.2"></script>
  <link rel="stylesheet" href="/lib/pace/pace-theme-minimal.min.css?v=1.0.2">


<script id="hexo-configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Gemini',
    version: '7.3.0',
    sidebar: {"position":"left","display":"post","offset":12,"onmobile":false},
    back2top: {"enable":true,"sidebar":false,"scrollpercent":true},
    save_scroll: false,
    copycode: {"enable":false,"show_result":false,"style":null},
    fancybox: false,
    mediumzoom: false,
    lazyload: false,
    pangu: false,
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    },
    localsearch: {"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},
    path: 'search.xml',
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    translation: {
      copy_button: '复制',
      copy_success: '复制成功',
      copy_failure: '复制失败'
    }
  };
</script>

  <meta name="description" content="简介pip是一个以Python计算机程序语言写成的软件包管理系统,他可以安装和管理软件包,另外不少的软件包也可以在“Python软件包索引”(英语:Python Package Index,简称PyPI)中找到。pip3就是Python3的pip。">
<meta name="keywords" content="centos7,Python">
<meta property="og:type" content="article">
<meta property="og:title" content="Python学习笔记三pip介绍及国内镜像源加速">
<meta property="og:url" content="https://crazyrico.com/posts/2020/05/08/3ea54810.html">
<meta property="og:site_name" content="疯狂的企鹅">
<meta property="og:description" content="简介pip是一个以Python计算机程序语言写成的软件包管理系统,他可以安装和管理软件包,另外不少的软件包也可以在“Python软件包索引”(英语:Python Package Index,简称PyPI)中找到。pip3就是Python3的pip。">
<meta property="og:locale" content="zh-CN">
<meta property="og:image" content="http://static.nsoft.vip/20200507155359.png">
<meta property="og:image" content="http://static.nsoft.vip/20200507174344.png">
<meta property="og:image" content="http://static.nsoft.vip/20200508092014.png">
<meta property="og:image" content="http://static.nsoft.vip/20200508092506.png">
<meta property="og:updated_time" content="2020-05-08T06:06:45.880Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Python学习笔记三pip介绍及国内镜像源加速">
<meta name="twitter:description" content="简介pip是一个以Python计算机程序语言写成的软件包管理系统,他可以安装和管理软件包,另外不少的软件包也可以在“Python软件包索引”(英语:Python Package Index,简称PyPI)中找到。pip3就是Python3的pip。">
<meta name="twitter:image" content="http://static.nsoft.vip/20200507155359.png">
  <link rel="alternate" href="/atom.xml" title="疯狂的企鹅" type="application/atom+xml">
  <link rel="canonical" href="https://crazyrico.com/posts/2020/05/08/3ea54810">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome: false,
    isPost: true,
    isPage: false,
    isArchive: false
  };
</script>

  <title>Python学习笔记三pip介绍及国内镜像源加速 | 疯狂的企鹅</title>
  








  <noscript>
  <style>
  .use-motion .motion-element,
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-title { opacity: initial; }

  .use-motion .logo,
  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-CN">

  <div class="container sidebar-position-left">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta">

    <div class="custom-logo-site-title">
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">疯狂的企鹅</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
        <p class="site-subtitle">Crazy.Rico's Blog</p>
      
  </div>

  <div class="site-nav-toggle">
    <button aria-label="切换导航栏">
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>


<nav class="site-nav">
  
  <ul id="menu" class="menu">
      
      
      
        
        <li class="menu-item menu-item-home">
      
    

    <a href="/" rel="section"><i class="menu-item-icon fa fa-fw fa-home"></i> <br>首页</a>

  </li>
      
      
      
        
        <li class="menu-item menu-item-archives">
      
    

    <a href="/archives/" rel="section"><i class="menu-item-icon fa fa-fw fa-archive"></i> <br>归档</a>

  </li>
      
      
      
        
        <li class="menu-item menu-item-about">
      
    

    <a href="/about/" rel="section"><i class="menu-item-icon fa fa-fw fa-user"></i> <br>关于</a>

  </li>
      
      
      
        
        <li class="menu-item menu-item-tags">
      
    

    <a href="/tags/" rel="section"><i class="menu-item-icon fa fa-fw fa-tags"></i> <br>标签</a>

  </li>
      
      
      
        
        <li class="menu-item menu-item-categories">
      
    

    <a href="/categories/" rel="section"><i class="menu-item-icon fa fa-fw fa-th"></i> <br>分类</a>

  </li>
      
      
      
        
        <li class="menu-item menu-item-links">
      
    

    <a href="/links/" rel="section"><i class="menu-item-icon fa fa-fw fa-chain"></i> <br>links</a>

  </li>
      <li class="menu-item menu-item-search">
        <a href="javascript:;" class="popup-trigger">
        
          <i class="menu-item-icon fa fa-search fa-fw"></i> <br>搜索</a>
      </li>
    
  </ul>

    <div class="site-search">
      
  <div class="popup search-popup local-search-popup">
  <div class="local-search-header clearfix">
    <span class="search-icon">
      <i class="fa fa-search"></i>
    </span>
    <span class="popup-btn-close">
      <i class="fa fa-times-circle"></i>
    </span>
    <div class="local-search-input-wrapper">
      <input autocomplete="off"
             placeholder="搜索..." spellcheck="false"
             type="text" id="local-search-input">
    </div>
  </div>
  <div id="local-search-result"></div>
</div>


    </div>
</nav>
</div>
    </header>

    

  <a href="https://github.com/crazyrico" class="github-corner" title="Follow me on GitHub" aria-label="Follow me on GitHub" rel="noopener" target="_blank"><svg width="80" height="80" viewBox="0 0 250 250" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a>


    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
            

          <div id="content" class="content page-post-detail">
            

  <div id="posts" class="posts-expand">
    

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://crazyrico.com/posts/2020/05/08/3ea54810.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Crazy Rico">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="http://static.nsoft.vip/penguin.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="疯狂的企鹅">
    </span>
      <header class="post-header">

        
          <h1 class="post-title" itemprop="name headline">Python学习笔记三pip介绍及国内镜像源加速

            
          </h1>
        

        <div class="post-meta">
		   
		  <!-- add by alex.yao 2019-10-17 begin -->
		   
		  <!-- add by alex.yao 2019-10-17 end -->
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              
                
              

              <time title="创建时间：2020-05-08 18:20:21 / 修改时间：14:06:45" itemprop="dateCreated datePublished" datetime="2020-05-08T18:20:21+08:00">2020-05-08</time>
            </span>
          
            

            
          
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing"><a href="/categories/Python/" itemprop="url" rel="index"><span itemprop="name">Python</span></a></span>

                
                
              
            </span>
          

          
            <span class="post-meta-item" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="busuanzi-value" id="busuanzi_value_page_pv"></span>
            </span>
          
          <br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="fa fa-file-word-o"></i>
              </span>
              
                <span class="post-meta-item-text">本文字数：</span>
              
              <span>6.4k</span>
            </span>
          
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="fa fa-clock-o"></i>
              </span>
              
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              
              <span>6 分钟</span>
            </span>
          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <h2 id="简介"><a href="#简介" class="headerlink" title="简介"></a>简介</h2><p>pip是一个以Python计算机程序语言写成的软件包管理系统,他可以安装和管理软件包,另外不少的软件包也可以在“Python软件包索引”(英语:Python Package Index,简称PyPI)中找到。<br>pip3就是Python3的pip。</p>
<p><img src="http://static.nsoft.vip/20200507155359.png" alt=""></p>
<a id="more"></a>

<h2 id="命令行接口"><a href="#命令行接口" class="headerlink" title="命令行接口"></a>命令行接口</h2><p>pip 的其中一个主要特点就是其方便使用的命令行接口，这让用户可以透过以下的一句文字命令来轻易地安装 Python 软件包：</p>
<figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">pip install &lt;包名&gt;</span><br></pre></td></tr></tbody></table></figure>

<p>此外，用户也可以轻易地透过以下的命令来移除软件包：</p>
<figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">pip uninstall &lt;包名&gt;</span><br></pre></td></tr></tbody></table></figure>

<p>升级软件包：</p>
<figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">pip install -U &lt;包名&gt;</span><br><span class="line">或者</span><br><span class="line">pip install &lt;包名&gt; --upgrade</span><br></pre></td></tr></tbody></table></figure>

<p>pip 也拥有一个透过“需求”文件来管理软件包和其相应版本数目的完整列表之功能，这容许一个完整软件包组合可以在另一个环境（如另一部计算机）或虚拟化环境中进行有效率的重新创造。这个功能可以透过一个已正确进行格式化的文本文件和以下的命令来完成：</p>
<figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">pip install -r requirements.txt</span><br></pre></td></tr></tbody></table></figure>

<p>显示软件包所在的目录：</p>
<figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">pip show -f &lt;包名&gt;</span><br></pre></td></tr></tbody></table></figure>

<p>搜索包：</p>
<figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">pip search &lt;搜索关键字&gt;</span><br></pre></td></tr></tbody></table></figure>

<p>查询可升级的包：</p>
<figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">pip list -o</span><br></pre></td></tr></tbody></table></figure>

<p>打包：</p>
<figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">pip wheel &lt;包名&gt;</span><br></pre></td></tr></tbody></table></figure>

<h2 id="错误"><a href="#错误" class="headerlink" title="错误"></a>错误</h2><p>在命令窗口输入pip3 install numpy，安装报错，出现一大堆类似下图红色的错误, 心中一万头草泥马</p>
<p><img src="http://static.nsoft.vip/20200507174344.png" alt=""></p>
<figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br></pre></td><td class="code"><pre><span class="line">E:\Work\Code&gt;python <span class="string">"Day 1_Data_Preprocessing.py"</span></span><br><span class="line">Traceback (most recent call last):</span><br><span class="line">  File <span class="string">"Day 1_Data_Preprocessing.py"</span>, line 4, <span class="keyword">in</span> &lt;module&gt;</span><br><span class="line">    import numpy as np</span><br><span class="line">ModuleNotFoundError: No module named <span class="string">'numpy'</span></span><br><span class="line"></span><br><span class="line">E:\Work\Code&gt;pip3 install numpy</span><br><span class="line">Collecting numpy</span><br><span class="line">  Downloading https://files.pythonhosted.org/packages/99/29/080d63fb9579b426ea8081dc3f49f89e51912e0fb7d5be4a65cfa87e3898/numpy-1.18.3-cp37-cp37m-win_amd64.whl (12.8MB)</span><br><span class="line">     |                                | 10kB 434bytes/s eta 8:09:36ERROR: Exception:</span><br><span class="line">Traceback (most recent call last):</span><br><span class="line">  File <span class="string">"d:\python\python37\lib\site-packages\pip\_vendor\urllib3\response.py"</span>, line 425, <span class="keyword">in</span> _error_catcher</span><br><span class="line">    yield</span><br><span class="line">  File <span class="string">"d:\python\python37\lib\site-packages\pip\_vendor\urllib3\response.py"</span>, line 507, <span class="keyword">in</span> <span class="built_in">read</span></span><br><span class="line">    data = self._fp.read(amt) <span class="keyword">if</span> not fp_closed <span class="keyword">else</span> b<span class="string">""</span></span><br><span class="line">  File <span class="string">"d:\python\python37\lib\site-packages\pip\_vendor\cachecontrol\filewrapper.py"</span>, line 62, <span class="keyword">in</span> <span class="built_in">read</span></span><br><span class="line">    data = self.__fp.read(amt)</span><br><span class="line">  File <span class="string">"d:\python\python37\lib\http\client.py"</span>, line 457, <span class="keyword">in</span> <span class="built_in">read</span></span><br><span class="line">    n = self.readinto(b)</span><br><span class="line">  File <span class="string">"d:\python\python37\lib\http\client.py"</span>, line 501, <span class="keyword">in</span> readinto</span><br><span class="line">    n = self.fp.readinto(b)</span><br><span class="line">  File <span class="string">"d:\python\python37\lib\socket.py"</span>, line 589, <span class="keyword">in</span> readinto</span><br><span class="line">    <span class="built_in">return</span> self._sock.recv_into(b)</span><br><span class="line">  File <span class="string">"d:\python\python37\lib\ssl.py"</span>, line 1071, <span class="keyword">in</span> recv_into</span><br><span class="line">    <span class="built_in">return</span> self.read(nbytes, buffer)</span><br><span class="line">  File <span class="string">"d:\python\python37\lib\ssl.py"</span>, line 929, <span class="keyword">in</span> <span class="built_in">read</span></span><br><span class="line">    <span class="built_in">return</span> self._sslobj.read(len, buffer)</span><br><span class="line">socket.timeout: The <span class="built_in">read</span> operation timed out</span><br><span class="line"></span><br><span class="line">During handling of the above exception, another exception occurred:</span><br><span class="line"></span><br><span class="line">Traceback (most recent call last):</span><br><span class="line">  File <span class="string">"d:\python\python37\lib\site-packages\pip\_internal\cli\base_command.py"</span>, line 153, <span class="keyword">in</span> _main</span><br><span class="line">    status = self.run(options, args)</span><br><span class="line">  File <span class="string">"d:\python\python37\lib\site-packages\pip\_internal\commands\install.py"</span>, line 382, <span class="keyword">in</span> run</span><br><span class="line">    resolver.resolve(requirement_set)</span><br><span class="line">  File <span class="string">"d:\python\python37\lib\site-packages\pip\_internal\legacy_resolve.py"</span>, line 201, <span class="keyword">in</span> resolve</span><br><span class="line">    self._resolve_one(requirement_set, req)</span><br><span class="line">  File <span class="string">"d:\python\python37\lib\site-packages\pip\_internal\legacy_resolve.py"</span>, line 365, <span class="keyword">in</span> _resolve_one</span><br><span class="line">    abstract_dist = self._get_abstract_dist_for(req_to_install)</span><br><span class="line">  File <span class="string">"d:\python\python37\lib\site-packages\pip\_internal\legacy_resolve.py"</span>, line 313, <span class="keyword">in</span> _get_abstract_dist_for</span><br><span class="line">    req, self.session, self.finder, self.require_hashes</span><br><span class="line">  File <span class="string">"d:\python\python37\lib\site-packages\pip\_internal\operations\prepare.py"</span>, line 194, <span class="keyword">in</span> prepare_linked_requirement</span><br><span class="line">    progress_bar=self.progress_bar</span><br><span class="line">  File <span class="string">"d:\python\python37\lib\site-packages\pip\_internal\download.py"</span>, line 465, <span class="keyword">in</span> unpack_url</span><br><span class="line">    progress_bar=progress_bar</span><br><span class="line">  File <span class="string">"d:\python\python37\lib\site-packages\pip\_internal\download.py"</span>, line 316, <span class="keyword">in</span> unpack_http_url</span><br><span class="line">    progress_bar)</span><br><span class="line">  File <span class="string">"d:\python\python37\lib\site-packages\pip\_internal\download.py"</span>, line 551, <span class="keyword">in</span> _download_http_url</span><br><span class="line">    _download_url(resp, link, content_file, hashes, progress_bar)</span><br><span class="line">  File <span class="string">"d:\python\python37\lib\site-packages\pip\_internal\download.py"</span>, line 253, <span class="keyword">in</span> _download_url</span><br><span class="line">    hashes.check_against_chunks(downloaded_chunks)</span><br><span class="line">  File <span class="string">"d:\python\python37\lib\site-packages\pip\_internal\utils\hashes.py"</span>, line 80, <span class="keyword">in</span> check_against_chunks</span><br><span class="line">    <span class="keyword">for</span> chunk <span class="keyword">in</span> chunks:</span><br><span class="line">  File <span class="string">"d:\python\python37\lib\site-packages\pip\_internal\download.py"</span>, line 223, <span class="keyword">in</span> written_chunks</span><br><span class="line">    <span class="keyword">for</span> chunk <span class="keyword">in</span> chunks:</span><br><span class="line">  File <span class="string">"d:\python\python37\lib\site-packages\pip\_internal\utils\ui.py"</span>, line 160, <span class="keyword">in</span> iter</span><br><span class="line">    <span class="keyword">for</span> x <span class="keyword">in</span> it:</span><br><span class="line">  File <span class="string">"d:\python\python37\lib\site-packages\pip\_internal\download.py"</span>, line 212, <span class="keyword">in</span> resp_read</span><br><span class="line">    decode_content=False):</span><br><span class="line">  File <span class="string">"d:\python\python37\lib\site-packages\pip\_vendor\urllib3\response.py"</span>, line 564, <span class="keyword">in</span> stream</span><br><span class="line">    data = self.read(amt=amt, decode_content=decode_content)</span><br><span class="line">  File <span class="string">"d:\python\python37\lib\site-packages\pip\_vendor\urllib3\response.py"</span>, line 529, <span class="keyword">in</span> <span class="built_in">read</span></span><br><span class="line">    raise IncompleteRead(self._fp_bytes_read, self.length_remaining)</span><br><span class="line">  File <span class="string">"d:\python\python37\lib\contextlib.py"</span>, line 130, <span class="keyword">in</span> __exit__</span><br><span class="line">    self.gen.throw(<span class="built_in">type</span>, value, traceback)</span><br><span class="line">  File <span class="string">"d:\python\python37\lib\site-packages\pip\_vendor\urllib3\response.py"</span>, line 430, <span class="keyword">in</span> _error_catcher</span><br><span class="line">    raise ReadTimeoutError(self._pool, None, <span class="string">"Read timed out."</span>)</span><br><span class="line">pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host=<span class="string">'files.pythonhosted.org'</span>, port=443): Read timed out.</span><br><span class="line">WARNING: You are using pip version 19.3.1; however, version 20.0.2 is available.</span><br><span class="line">You should consider upgrading via the <span class="string">'python -m pip install --upgrade pip'</span> <span class="built_in">command</span>.</span><br></pre></td></tr></tbody></table></figure>

<p>这是因为网络的问题，网络不畅下载软件包超时，可以使用国内的镜像源来加速,比如阿里源</p>
<h2 id="解决方案"><a href="#解决方案" class="headerlink" title="解决方案"></a>解决方案</h2><h3 id="方案一"><a href="#方案一" class="headerlink" title="方案一"></a>方案一</h3><p>pip3 install 加上 -i –trusted-host  阿里源镜像地址</p>
<figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">E:\Work\Code&gt;pip3 install numpy -i http://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com</span><br><span class="line">Looking <span class="keyword">in</span> indexes: http://mirrors.aliyun.com/pypi/simple</span><br><span class="line">Collecting numpy</span><br><span class="line">  Downloading http://mirrors.aliyun.com/pypi/packages/99/29/080d63fb9579b426ea8081dc3f49f89e51912e0fb7d5be4a65cfa87e3898/numpy-1.18.3-cp37-cp37m-win_amd64.whl (12.8MB)</span><br><span class="line">     |████████████████████████████████| 12.8MB 6.8MB/s</span><br><span class="line">Installing collected packages: numpy</span><br><span class="line">Successfully installed numpy-1.18.3</span><br><span class="line">WARNING: You are using pip version 19.3.1; however, version 20.0.2 is available.</span><br><span class="line">You should consider upgrading via the <span class="string">'python -m pip install --upgrade pip'</span> <span class="built_in">command</span>.</span><br></pre></td></tr></tbody></table></figure>

<p>perfect, 速度杠杠的</p>
<h3 id="方案二"><a href="#方案二" class="headerlink" title="方案二"></a>方案二</h3><p>当然我还是喜欢一劳永逸的方法，每次install 都要带上一长串镜像地址参数实在<br><img src="http://static.nsoft.vip/20200508092014.png" alt=""></p>
<p>下面开始我的表演，进入系统 %AppData% 就是 C:\Users\用户名\AppData\Roaming<br><img src="http://static.nsoft.vip/20200508092506.png" alt=""><br>在这个目录下创建一个pip文件夹，在pip文件夹下新建pip.ini文件，打开pip.ini配置国内镜像源输入内容如下</p>
<figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">[global]</span><br><span class="line">timeout = 6000</span><br><span class="line">index-url = http://mirrors.aliyun.com/pypi/simple</span><br><span class="line">trusted-host = mirrors.aliyun.com</span><br></pre></td></tr></tbody></table></figure>

<p>保存退出，欧了这样每次install 都会使用国内镜像加速</p>
<p>Linux下，修改 ~/.pip/pip.conf (没有就创建一个文件夹及文件。文件夹要加“.”，表示是隐藏文件夹)</p>
<figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">[global]</span><br><span class="line">index-url = http://mirrors.aliyun.com/pypi/simple</span><br><span class="line">[install]</span><br><span class="line">trusted-host = mirrors.aliyun.com</span><br></pre></td></tr></tbody></table></figure>

<h3 id="方案三"><a href="#方案三" class="headerlink" title="方案三"></a>方案三</h3><p>当然你还可以写几行python完成上面的操作，创建python文件（xx.py）</p>
<figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">import os </span><br><span class="line"> </span><br><span class="line">ini=<span class="string">""</span><span class="string">"[global]</span></span><br><span class="line"><span class="string">index-url = https://pypi.doubanio.com/simple/</span></span><br><span class="line"><span class="string">[install]</span></span><br><span class="line"><span class="string">trusted-host=pypi.doubanio.com</span></span><br><span class="line"><span class="string">"</span><span class="string">""</span> </span><br><span class="line">pippath=os.environ[<span class="string">"USERPROFILE"</span>]+<span class="string">"\\pip\\"</span> </span><br><span class="line"> </span><br><span class="line"><span class="keyword">if</span> not os.path.exists(pippath): </span><br><span class="line">    os.mkdir(pippath) </span><br><span class="line"> </span><br><span class="line">with open(pippath+<span class="string">"pip.ini"</span>,<span class="string">"w+"</span>) as f: </span><br><span class="line">    f.write(ini)</span><br></pre></td></tr></tbody></table></figure>

<p>在cmd上运行这个xx.py 文件，效果与二相同</p>
<figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">python .\xx.py</span><br></pre></td></tr></tbody></table></figure>

<h2 id="常用国内镜像"><a href="#常用国内镜像" class="headerlink" title="常用国内镜像"></a>常用国内镜像</h2><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">https://pypi.tuna.tsinghua.edu.cn/simple/	<span class="comment"># 清华大学</span></span><br><span class="line">https://mirrors.aliyun.com/pypi/simple/		<span class="comment"># 阿里云</span></span><br><span class="line">https://pypi.douban.com/simple/				<span class="comment"># 豆瓣</span></span><br><span class="line">https://pypi.mirrors.ustc.edu.cn/simple/	<span class="comment"># 中国科学技术大学</span></span><br><span class="line">https://pypi.hustunique.com/				<span class="comment"># 华中科技大学</span></span><br></pre></td></tr></tbody></table></figure><script>
        document.querySelectorAll('.github-emoji')
          .forEach(el => {
            if (!el.dataset.src) { return; }
            const img = document.createElement('img');
            img.style = 'display:none !important;';
            img.src = el.dataset.src;
            img.addEventListener('error', () => {
              img.remove();
              el.style.color = 'inherit';
              el.style.backgroundImage = 'none';
              el.style.background = 'none';
            });
            img.addEventListener('load', () => {
              img.remove();
            });
            document.body.appendChild(img);
          });
      </script>
    </div>

    
    
    
	
	<!-- add by alex.yao 2019-08-07 begin -->
	<div>
    
      <!-- add 2018-12-29 -->
<div>
    
        <div style="text-align:center;color: #ccc;font-size:14px;">-------------本文结束<i class="fa fa-paw"></i>感谢您的阅读-------------</div>
    
</div>
    
    </div>
    <!-- add by alex.yao 2019-08-07 end -->
      <div id="wechat_subscriber" style="display: block; padding: 10px 0; margin: 20px auto; width: 100%; text-align: center;">
  <img id="wechat_subscriber_qcode" src="http://static.nsoft.vip/qrcode_for_tec.jpg" alt="Crazy Rico wechat" style="width: 200px; max-width: 100%;">
  <div>欢迎您扫一扫上面的微信公众号，订阅我的博客！</div>
</div>

    
      <div>
        <div id="reward-container">
  <div></div>
  <button id="reward-button" disable="enable" onclick="var qr = document.getElementById(&quot;qr&quot;); qr.style.display = (qr.style.display === 'none') ? 'block' : 'none';">
    打赏
  </button>
  <div id="qr" style="display: none;">
        
      
      <div style="display: inline-block">
        <img src="http://static.nsoft.vip/weixin.png" alt="Crazy Rico 微信支付">
        <p>微信支付</p>
      </div>
        
      
      <div style="display: inline-block">
        <img src="http://static.nsoft.vip/alipay.jpg" alt="Crazy Rico 支付宝">
        <p>支付宝</p>
      </div>

  </div>
</div>

      </div>

    <footer class="post-footer">
          
        
        <div class="post-tags">
            <a href="/tags/centos7/" rel="tag"># centos7</a>
          
            <a href="/tags/Python/" rel="tag"># Python</a>
          
        </div>
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
              <a href="/posts/2020/04/25/bd822cee.html" rel="next" title="Python学习笔记二Hello Python">
                <i class="fa fa-chevron-left"></i> Python学习笔记二Hello Python
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
          </div>
        </div>
    </footer>
  </div>
  
  
  
  </article>

  </div>


          </div>
          
    
    <div class="comments" id="gitalk-container"></div>
  


        </div>
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-overview">

          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image"
      src="http://static.nsoft.vip/penguin.png"
      alt="Crazy Rico">
  <p class="site-author-name" itemprop="name">Crazy Rico</p>
  <div class="site-description motion-element" itemprop="description"></div>
</div>
  <nav class="site-state motion-element">
      <div class="site-state-item site-state-posts">
        
          <a href="/archives/">
        
          <span class="site-state-item-count">33</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
    
      
      
      <div class="site-state-item site-state-categories">
        
          
            <a href="/categories/">
          
        
        
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
        <span class="site-state-item-count">17</span>
        <span class="site-state-item-name">分类</span>
        </a>
      </div>
    
      
      
      <div class="site-state-item site-state-tags">
        
          
            <a href="/tags/">
          
        
        
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
        <span class="site-state-item-count">39</span>
        <span class="site-state-item-name">标签</span>
        </a>
      </div>
    
  </nav>
  <div class="feed-link motion-element">
    <a href="/atom.xml" rel="alternate">
      <i class="fa fa-rss"></i>RSS
    </a>
  </div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
      
      
        
      
      
        
      
        <a href="https://github.com/crazyrico" title="GitHub &rarr; https://github.com/crazyrico" rel="noopener" target="_blank"><i class="fa fa-fw fa-github"></i>GitHub</a>
      </span>
    
      <span class="links-of-author-item">
      
      
        
      
      
        
      
        <a href="https://www.freecodecamp.cn/crazyrico" title="FCC &rarr; https://www.freecodecamp.cn/crazyrico" rel="noopener" target="_blank"><i class="fa fa-fw fa-globe"></i>FCC</a>
      </span>
    
      <span class="links-of-author-item">
      
      
        
      
      
        
      
        <a href="mailto:crazyrico@qq.com" title="E-Mail &rarr; mailto:crazyrico@qq.com" rel="noopener" target="_blank"><i class="fa fa-fw fa-envelope"></i>E-Mail</a>
      </span>
    
      <span class="links-of-author-item">
      
      
        
      
      
        
      
        <a href="https://s.imooc.com/ACFNlyI" title="慕课网 &rarr; https://s.imooc.com/ACFNlyI" rel="noopener" target="_blank"><i class="fa fa-fw fa-fire"></i>慕课网</a>
      </span>
    
      <span class="links-of-author-item">
      
      
        
      
      
        
      
        <a href="https://promotion.aliyun.com/ntms/yunparter/invite.html?userCode=gr9asv3c" title="阿里云 &rarr; https://promotion.aliyun.com/ntms/yunparter/invite.html?userCode=gr9asv3c" rel="noopener" target="_blank"><i class="fa fa-fw fa-cloud"></i>阿里云</a>
      </span>
    
  </div>



        </div>
      </div>
      <!--noindex-->
        <div class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
            
            
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#简介"><span class="nav-number">1.</span> <span class="nav-text">简介</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#命令行接口"><span class="nav-number">2.</span> <span class="nav-text">命令行接口</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#错误"><span class="nav-number">3.</span> <span class="nav-text">错误</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#解决方案"><span class="nav-number">4.</span> <span class="nav-text">解决方案</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#方案一"><span class="nav-number">4.1.</span> <span class="nav-text">方案一</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#方案二"><span class="nav-number">4.2.</span> <span class="nav-text">方案二</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#方案三"><span class="nav-number">4.3.</span> <span class="nav-text">方案三</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#常用国内镜像"><span class="nav-number">5.</span> <span class="nav-text">常用国内镜像</span></a></li></ol></div>
            

          </div>
        </div>
      <!--/noindex-->
      

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">  <a href="http://www.beian.miit.gov.cn" rel="noopener" target="_blank">苏ICP备17004952号 </a>&copy; <span itemprop="copyrightYear">2020</span>
  <span class="with-love" id="animate">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Crazy Rico</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-area-chart"></i>
    </span>
    <span title="站点总字数">90k</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
    <span title="站点阅读时长">1:22</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io" class="theme-link" rel="noopener" target="_blank">Hexo</a> 强力驱动 v3.9.0</div>
  <span class="post-meta-divider">|</span>
  <div class="theme-info">主题 – <a href="https://theme-next.org" class="theme-link" rel="noopener" target="_blank">NexT.Gemini</a> v7.3.0</div>

        
<div class="busuanzi-count">
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
    <span class="post-meta-item-icon">
      <i class="fa fa-user"></i>
    </span>
    <span class="site-uv" title="总访客量">
      <span class="busuanzi-value" id="busuanzi_value_site_uv"></span>
    </span>
  
    <span class="post-meta-divider">|</span>
  
    <span class="post-meta-item-icon">
      <i class="fa fa-eye"></i>
    </span>
    <span class="site-pv" title="总访问量">
      <span class="busuanzi-value" id="busuanzi_value_site_pv"></span>
    </span>
  
</div>


  <!--
  <div style="display: none;">
    <script src="//s95.cnzz.com/z_stat.php?id=true&web_id=true"></script>
  </div>
  -->
  <script type="text/javascript">var cnzz_protocol = (("https:" == document.location.protocol) ? "https://" : "http://");document.write(unescape("%3Cspan id='cnzz_stat_icon_1278118065'%3E%3C/span%3E%3Cscript src='" + cnzz_protocol + "s9.cnzz.com/z_stat.php%3Fid%3D1278118065%26online%3D1%26show%3Dline' type='text/javascript'%3E%3C/script%3E"));</script>






        
      </div>
    </footer>
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
          <span id="scrollpercent"><span>0</span>%</span>
        
      </div>

    

  </div>

  
  <script src="/lib/jquery/index.js?v=3.4.1"></script>
  <script src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  <script src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

<script src="/js/utils.js?v=7.3.0"></script>
  <script src="/js/motion.js?v=7.3.0"></script>


  <script src="/js/affix.js?v=7.3.0"></script>
  <script src="/js/schemes/pisces.js?v=7.3.0"></script>



<script src="/js/next-boot.js?v=7.3.0"></script>






  















  <script src="/js/local-search.js?v=7.3.0"></script>













<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.css">

<script>
  NexT.utils.getScript('//cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.js', function() {
    var gitalk = new Gitalk({
      clientID: '9255016b522a1b91949f',
      clientSecret: 'a0344ceccbd072ddf864ace66c89f73e53bfb671',
      repo: 'CrazyRico.github.io',
      owner: 'CrazyRico',
      admin: ['CrazyRico'],
      id: '516a35d265e49707e113184afbcbb8c8',
        language: window.navigator.language || window.navigator.userLanguage,
      
      distractionFreeMode: 'true'
    });
    gitalk.render('gitalk-container');
  }, window.Gitalk);
</script>




  

  

  


  
  <script src="/js/scrollspy.js?v=7.3.0"></script>
<script src="/js/post-details.js?v=7.3.0"></script>


    
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.css">

<script>
  NexT.utils.getScript('//cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.js', function() {
    var gitalk = new Gitalk({
      clientID: '9255016b522a1b91949f',
      clientSecret: 'a0344ceccbd072ddf864ace66c89f73e53bfb671',
      repo: 'CrazyRico.github.io',
      owner: 'CrazyRico',
      admin: ['CrazyRico'],
      id: '5d40071a7b5fac39e1e679f55100f8c8',
        language: window.navigator.language || window.navigator.userLanguage,
      
      distractionFreeMode: 'true'
    });
    gitalk.render('gitalk-container');
  }, window.Gitalk);
</script>

</body>
</html>
